<?php
include("includes/header.php") ?>
<title>LazySwim - Contact</title>
</head>

<body>
<div id="page">
    <div id="page-top">
        <div id="page-bottom">
          <div id="header">
                <div id="header-info">
                    <h1>LAZYSWIM</h1>
                    <div class="description">Simplistic Swim System</div>
                </div>
				<!-- Header Goes Here -->
                <?php printHeader(); ?>
				<!-- Header Ends Here -->
                <div id="header-date">Today is <?php echo date('l, F jS, Y'); ?></div>
                <div id="header-cats">
				<!-- Welcome Message Starts Here -->
                    <ul>
					<?php include("includes/welcomeBar.php"); ?>
					</ul>
				<!-- Welcome Message Ends Here -->	
                </div>
            </div>
            <div id="main">

                <div id="sidebar">
                    <?php
					// include the corresponding navigation page
                    include("includes/navigation.php");
					?>     
                </div>

<!-- main body -->

                <div class="featured-post">
                    <div class="post-title">
                        <h2><?php echo $currentPageTitle; ?></h2>
					</div>
                    <div class="post-entry">
					<?php if($_POST['submit']) {
					
					$manageremail = "awesys@hotmail.com";
					
					$email = $HTTP_POST_VARS['email'];
					$subject = $HTTP_POST_VARS['subject'];
					$message = $HTTP_POST_VARS['message'];

					$message .= "\n\nSent from $email";
					
					// Validate form - check for valid email address and non-empty subject field
					if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
					  echo "<p>Invalid email address! Please go back and check your speling.</p>";
					  echo "<a href='javascript:history.back(1);'>Back</a>";
					} elseif ($subject == "") {
					  echo "<p>Subject missing! Please go back and enter a Subject.</p>";
					  echo "<a href='javascript:history.back(1);'>Back</a>";
					}
					
					// Sends mail and outputs Thank you if successful, or the error string otherwise.
					elseif (mail($manageremail,$subject,$message)) {
					  echo "<p>Thank you for sending your message!</p>";
					} else {
					  echo "<p>Can't send email to $email</p>";
					}
					
					
					
					}     else { ?>
						<p>Please fill out the form below to email our team manager!</p>

						<form action="contact.php" method="post">
						<p>
						<b>Your Email</b><br />
						<input type="text" name="email" size="40" />
						</p>
						<p>
						<b>Subject</b><br />
						<input type="text" name="subject" size="40" />
						</p>
						<p>
						<b>Message</b><br />
						<textarea cols="40" rows="10" name="message"></textarea>
						</p>
						<input type="submit" value=" Send " name="submit" />
						</form>
						<?php } ?>
                    </div>
                </div>
             
                <div class="clear"></div>

            </div>
			<!-- Footer Goes Here -->
            <?php include("includes/footer.php"); ?>
			<!-- Footer Ends Here -->
        </div>
    </div>
</div>
</body>
</html>
